<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:p="http://primefaces.org/ui">    

    <body>
        <ui:composition template="/pages/protected/templates/master.xhtml">           
            <ui:define  name="divTop">
                <h1>Tipo de Cozinhas</h1>
            </ui:define>

            <ui:define  name="divMain">
                <h:form id="form" prependId="false">
                    <h:panelGrid id="painel" columns="3">
                        
                        <h:outputText value="* #{bundle.tpoCozinhasDescricao}" />
                        <p:inputText id="descricao"
                                     value="#{tipodeCozinhasModel.TCozinha.descricao}" required="true" label="#{bundle.tpoCozinhasDescricao}"/>
                        <p:message  for="descricao" display="icon" /> 

                        <p:commandButton value="#{bundle.create}" id="create"
                                         action="#{tipodeCozinhasModel.salvar()}"
                                         update="painel, tabledata" />
                        <p:commandButton value="#{bundle.update}" id="update"
                                         actionListener="#{tipodeCozinhasModel.atualizar()}"
                                         update="painel,tabledata" />  
                    </h:panelGrid>
                    <br/>

                    <p:dataTable id="tabledata" var="coz" value="#{tipodeCozinhasModel.carregarTodosTCozinhas()}" 
                                 rowKey="#{coz}" paginator="true" rows="10" 
                                 selection="#{tipodeCozinhasModel.cozinhaSelecionada}" selectionMode="single">                          
                        <p:ajax event="rowSelect" listener="#{tipodeCozinhasModel.onRowSelect}"
                                update=":form:display" />

                        <f:facet name="header">  
                            Click "View" button after selecting a row to see details  
                        </f:facet> 
                        <p:column headerText="#{bundle.tpoCozinhasDescricao}" width="50%"
                                  filterBy="#{coz.descricao}" footerText="contains"
                                  filterMatchMode="contains">  
                            #{coz.descricao}  
                        </p:column>  

                        <f:facet name="footer">  
                            <p:commandButton id="viewButton" value="#{bundle.view}" icon="ui-icon-search"  
                                             update=":form:display" onclick="DialogView.show()"
                                             title="#{bundle.view}">                                                                                    
                            </p:commandButton> 

                            <p:commandButton id="alterarButton" value="#{bundle.update}" 
                                             icon="ui-icon-arrowrefresh-1-w"  
                                             update=":form:display" onclick=""
                                             title="#{bundle.update}">                                                                                    
                            </p:commandButton> 

                            <p:commandButton id="excluirButton" value="#{bundle.delete}" icon="ui-icon-close"  
                                             update=":form:display" onclick="confirmation.show()"
                                             title="#{bundle.delete}">                                                                                    
                            </p:commandButton> 

                        </f:facet>  

                    </p:dataTable>  

                    <p:confirmDialog id="confirmDialog"  message="Deseja realmente excluir?"  
                                     header="Excluir - Tipo de Cozinhas" severity="alert"  widgetVar="confirmation">  

                        <p:commandButton id="confirm" value="#{bundle.yes}"  oncomplete="confirmation.hide()"  
                                         immediate="true" actionListener="#{tipodeCozinhasModel.excluir()}" update="tabledata" />  
                        <p:commandButton id="decline" value="#{bundle.no}" onclick="confirmation.hide()" type="button" />   

                    </p:confirmDialog>



                    <p:dialog id="dialog"  header="Visualizar - Tipo de Cozinhas" widgetVar="DialogView" resizable="false"  
                              width="440" showEffect="clip" hideEffect="fold">  
                        <h:panelGrid id="display" columns="2" cellpadding="4">  
                            <h:outputText value="#{bundle.tpoCozinhasDescricao}" />  
                            <h:outputText value="#{tipodeCozinhasModel.cozinhaSelecionada.descricao}" />  

                        </h:panelGrid>                          
                    </p:dialog>      
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
